home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / asm / utils / digitalclock / digitalclock.asm next >
Encoding:
Assembly Source File  |  1980-01-04  |  5.6 KB  |  285 lines

  1. ;
  2. ;#%a %s -ot:%f.o -iai: -iai:ss -q100
  3. ;#%l FROM lib:segsplit.o t:%f.o TO %f LIBRARY lib:sslib.lib lib:amiga.lib
  4. ;#delete t:%f.o
  5. ;
  6. ;
  7. ; ### DigiClock by JM & TM v 1.51 ###
  8. ;
  9. ; - Created 880612 by JM & TM -
  10. ;
  11. ;
  12. ; Program written for the 'C' Magazine.  Segment drawing by TM.
  13. ; Code is not very beautiful but we wanted to keep it as short as
  14. ; possible.
  15. ;
  16. ; Bugs: None alive.
  17. ;
  18. ;
  19. ; Edited:
  20. ;
  21. ; - 880612 by JM,TM -> v0.50    - Works.
  22. ; - 880613 by JM    -> v1.00    - Code compressed.
  23. ; - 880613 by JM    -> v1.10    - Close button added; code compressed.
  24. ; - 880613 by JM,TM -> v1.40    - Code still compressed.  Length was 952
  25. ;                  bytes but was then cut down to 816 bytes.
  26. ; - 880725 by JM    -> v1.41    - IDCMP corrected.  CLOSEWINDOW must be
  27. ;                  checked with CMP.L!
  28. ; - 881106 by JM    -> v1.50    - Re-run enabled (doesn't modify itself)
  29. ; - 890312 by JM    -> v1.51    - Short branches, A68k compatibility
  30. ;
  31. ;
  32.  
  33.  
  34.  
  35.         xref    _LVOOpenLibrary
  36.         xref    _LVOCloseLibrary
  37.         xref    _LVOAllocMem
  38.         xref    _LVOFreeMem
  39.         xref    _LVODisable
  40.         xref    _LVOEnable
  41.         xref    _LVOWait
  42.         xref    _LVOGetMsg
  43.         xref    _LVOReplyMsg
  44.  
  45.         xref    _LVOExecute
  46.         xref    _LVOOpen
  47.         xref    _LVOClose
  48.         xref    _LVOOutput
  49.         xref    _LVORead
  50.         xref    _LVOWrite
  51.         xref    _LVODelay
  52.         xref    _LVODateStamp
  53.  
  54.         xref    _LVOMove
  55.         xref    _LVODraw
  56.         xref    _LVOText
  57.         xref    _LVOSetAPen
  58.         xref    _LVOSetBPen
  59.         xref    _LVOSetDrMd
  60.         xref    _LVOSetRast
  61.         xref    _LVOLoadRGB4
  62.         xref    _LVOVBeamPos
  63.  
  64.         xref    _LVOScreenToFront
  65.         xref    _LVOScreenToBack
  66.         xref    _LVOOpenScreen
  67.         xref    _LVOCloseScreen
  68.         xref    _LVOOpenWindow
  69.         xref    _LVOCloseWindow
  70.         xref    _LVOMoveScreen
  71.         xref    _LVOOpenFont
  72.         xref    _LVOCloseFont
  73.         xref    _LVOOpenDiskFont
  74.         xref    _LVORectFill
  75.  
  76.         xdef    main
  77.  
  78.         include "JMPLibs.i"
  79.         include "intuition.i"
  80.  
  81.         BITDEF    MEM,PUBLIC,0
  82.         BITDEF    MEM,CHIP,1
  83.         BITDEF    MEM,FAST,2
  84.         BITDEF    MEM,CLEAR,16
  85.         BITDEF    MEM,LARGEST,17
  86.  
  87. LF        equ    10
  88.  
  89.  
  90. tool_dclock
  91. main        openlib Dos,cleanup_dos        open Dos library
  92.         openlib    Gfx,cleanup_gfx
  93.         openlib    Intuition,cleanup_int
  94.  
  95.         clr.l    oldtime
  96.  
  97.         lea    ClWindow(pc),a0
  98.         lib    Intuition,OpenWindow
  99.         move.l    d0,d6            window ptr
  100.         beq    cleanup
  101.         move.l    d0,a0
  102.         move.l    wd_RPort(a0),a5        rastport
  103.  
  104.         moveq.l    #2,d0            Fill background
  105.         move.l    a5,a1
  106.         lib    Gfx,SetAPen
  107.         move.l    a5,a1
  108.         moveq.l    #2,d0
  109.         moveq.l    #10,d1
  110.         move.l    #311,d2
  111.         moveq.l    #77,d3
  112.         flib    Gfx,RectFill
  113.  
  114. Colon        moveq.l    #2,d0            Toggle colon color
  115.         bchg    #0,col_col
  116.         beq.s    Colon_off
  117.         addq.l    #1,d0
  118. Colon_off    move.l    a5,a1            Set color black/orange
  119.         lib    Gfx,SetAPen
  120.         move.l    a5,a1            Draw colon (upper dot)
  121.         move.l    #152,d0
  122.         moveq.l    #30,d1
  123.         move.l    d0,d2
  124.         addq.w    #8,d2
  125.         moveq.l    #34,d3
  126.         flib    Gfx,RectFill
  127.  
  128.         move.l    a5,a1            Draw colon (lower dot)
  129.         move.l    #152,d0
  130.         moveq.l    #52,d1
  131.         moveq.l    #56,d3
  132.         flib    Gfx,RectFill
  133.  
  134. Main        lea    TimeBuf(pc),a0        read time
  135.         move.l    a0,d1
  136.         lib    Dos,DateStamp
  137.  
  138.         move.l    TimeBuf+4(pc),d2
  139.         cmp.w    oldtime(pc),d2
  140.         beq.s    Sleep
  141.         move.w    d2,oldtime
  142.         divu.w    #60,d2            convert to hours/minutes
  143.         move.l    d2,d3            save minutes
  144.         moveq.l    #-68,d0            reset x-coord
  145.         bsr    draw2
  146.         swap    d3
  147.         move.l    d3,d2
  148.         bsr.s    draw2
  149.  
  150. Sleep        moveq.l    #24,d4
  151. WaitTicks    moveq.l    #1,d1            Sleep for a while
  152.         lib    Dos,Delay
  153.         move.l    d6,a0            windowptr
  154.         move.l    wd_UserPort(a0),a4
  155.         move.l    a4,a0            port*
  156.         lib    Exec,GetMsg        Check if a message received
  157. GetMsgLoop    move.l    d0,d2            message*
  158.         beq.s    Colonize        No msg received
  159.         move.l    d2,a1            IntuiMessage *
  160.         move.l    im_Class(a1),d3        Class
  161.         lib    Exec,ReplyMsg
  162.         move.l    a4,a0            port
  163.         flib    Exec,GetMsg
  164.         tst.l    d0
  165.         bne    GetMsgLoop
  166.         cmp.l    #CLOSEWINDOW,d3
  167.         beq.s    cleanup
  168. Colonize    dbf    d4,WaitTicks
  169.         bra    Colon
  170.  
  171.  
  172. cleanup        move.l    d6,d0
  173.         beq.s    clean90
  174.         move.l    d0,a0
  175.         lib    Intuition,CloseWindow
  176.  
  177. clean90        closl    Intuition
  178. cleanup_int    closl    Gfx
  179. cleanup_gfx    closl    Dos
  180. cleanup_dos    rts
  181.  
  182.  
  183. draw2        and.l    #$ffff,d2
  184.         divu.w    #10,d2
  185.         move.b    d2,d1        10 hours
  186.         add.w    #88,d0        xcoord
  187.         bsr.s    drawdigit
  188.         swap    d2        get hours
  189.         move.b    d2,d1
  190.         add.w    #68,d0        inc x
  191.  
  192. drawdigit    push    all        save registers
  193.         move.l    d0,d2        x-coordinate of the digit
  194.         lea    digitdata(pc),a0
  195.         ext.w    d1
  196.         move.b    0(a0,d1.w),d3    segment data
  197.         lsl.b    #1,d3
  198.         moveq.l    #6,d4
  199.         lea    segment(pc),a2
  200. drawdigit1    moveq.l    #2,d0
  201.         lsl.b    #1,d3
  202.         bcc.s    drawsegment1
  203.         moveq.l    #3,d0
  204. drawsegment1    move.l    a5,a1
  205.         lib    Gfx,SetAPen
  206.         moveq.l    #3,d7
  207. drawsegment2    moveq.l    #0,d0
  208.         move.l    d0,d1
  209.         move.b    (a2)+,d0
  210.         bmi.s    drawline1
  211.         move.b    (a2)+,d1
  212.         add.w    d2,d0
  213.         move.l    a5,a1
  214.         flib    Gfx,Move
  215.         moveq.l    #0,d0
  216.         move.l    d0,d1
  217.         move.b    (a2)+,d0
  218.         move.b    (a2)+,d1
  219.         add.w    d2,d0
  220.         move.l    a5,a1
  221.         flib    Gfx,Draw
  222. drawline1    dbf    d7,drawsegment2
  223.         dbf    d4,drawdigit1
  224.         pull    all        restore registers
  225.         rts
  226.  
  227. segment                ; segment coordinates
  228.         dc.b    2,20,45,20,3,21,44,21,4,22,43,22,-1
  229.                 ; segment A
  230.         dc.b    47,22,47,41,46,23,46,40,45,24,45,39,44,25,44,38
  231.                 ; segment B
  232.         dc.b    47,45,47,65,46,46,46,64,45,47,45,63,44,48,44,62
  233.                 ; segment C
  234.         dc.b    2,67,45,67,3,66,44,66,4,65,43,65,-1
  235.                 ; segment D
  236.         dc.b    0,45,0,65,1,46,1,64,2,47,2,63,3,48,3,62
  237.                 ; segment E
  238.         dc.b    0,22,0,41,1,23,1,40,2,24,2,39,3,25,3,38
  239.                 ; segment F
  240.         dc.b    4,42,43,42,2,43,45,43,4,44,43,44,-1
  241.                 ; segment G
  242.  
  243. digitdata    dc.b    %1111110    ; maaritellaan 7-segmenttinayton
  244.         dc.b    %0110000    ; numeroissa palavat segmentit
  245.         dc.b    %1101101
  246.         dc.b    %1111001
  247.         dc.b    %0110011
  248.         dc.b    %1011011
  249.         dc.b    %1011111
  250.         dc.b    %1110000
  251.         dc.b    %1111111
  252.         dc.b    %1111011
  253.  
  254.  
  255.         cnop    0,4            osoite 4:lla jaolliseksi
  256.  
  257. TimeBuf        dc.l    0
  258.         dc.l    0
  259.         dc.l    0
  260.  
  261. oldtime        dc.l    0
  262.         dc.l    0
  263.         dc.l    0
  264.  
  265. col_col        dc.w    0
  266.  
  267. ClWindow    dc.w    0,0,314,79        upper x,y , x,y-size
  268.         dc.b    2,1            detailpen, blockpen
  269.         dc.l    CLOSEWINDOW        IDCMPFlags
  270.         dc.l    WINDOWDRAG!WINDOWDEPTH!WINDOWCLOSE    Flags
  271.         dc.l    0            gadgets
  272.         dc.l    0            checkmark
  273.         dc.l    MyWinTitle        title
  274.         dc.l    0            screen
  275.         dc.l    0            bitmap
  276.         dc.w    320,256,320,256        min-max size
  277.         dc.w    WBENCHSCREEN        type
  278.  
  279. MyWinTitle    dc.b    'DigiCLOCK v1.51',0
  280.  
  281.         libnames            kirjastojen nimet&osoittimet
  282.  
  283.         end
  284.  
  285.